package com.liuqh.tag.easyexcel;

import java.io.File;
import java.util.List;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;

/**
 * @Author liuqinghua
 * @Date 2024/3/11 15:28
 */
public class MaskUtil {

    public static void main(String[] args) {
        String s = "2023423 客户：举报文集大通有限公司不交税2023423 客户：举报文集在大大通有限公司不交税914403001234567891abcdefg中国914403001234567891abcdefg";
        String reg1 = ".{6}有限公司";
        System.out.println(StringRegexReplacer.replaceWithRegex(s, reg1, "****有限公司"));
        String reg2 = "914403.{12}";
        System.out.println(StringRegexReplacer.replaceWithRegex(s, reg2, "914403****"));
        String reg3 = ".{6}有限公司|914403.{12}";
        System.out.println(StringRegexReplacer.replaceWithRegex(s, reg3, "ZZZ"));
    }

    public static void maskContent() {
        String inputDir = "e:/内容掩码/input";
        File f = new File(inputDir);
        File[] files = f.listFiles();
        for (File file : files) {
            String fileName = file.getName();
            String inputFilePath = inputDir + "/" + fileName;
            ExcelListen excelListen = new ExcelListen();
            EasyExcel.read(inputFilePath, ExcelData.class, excelListen).sheet().doRead();
            List<ExcelData> dataList = excelListen.getDataList();
            EasyExcel.write("e:/内容掩码/output/" + fileName).excelType(ExcelTypeEnum.XLSX).sheet("报表").doWrite(dataList);
        }
    }

}
